<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/base.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改用户密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${basePath}/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="${basePath}/css/public.css" media="all">
    <link rel="stylesheet" href="${basePath}/js/lay-module/step-lay/step.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding-top: 40px;">
                    <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                        <div carousel-item>
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">用户名:</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="account" placeholder="请输入您的用户名" class="layui-input" lay-verify="required|account" lay-reqtext="用户名不能为空"/>

                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">姓名:</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="realname" placeholder="请输入您的姓名" value="" class="layui-input" lay-verify="required|realname" lay-reqtext="姓名不能为空" required>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">电子邮箱:</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="email" placeholder="请输入您的电子邮箱" value="" class="layui-input" lay-verify="email" required>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">身份类型:</label>
                                        <div class="layui-input-block" >
                                            <select lay-verify="required" name="roleid">
                                                <option value="3" selected >学生</option>
                                                <option value="2" >教师</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">性别:</label>
                                        <div class="layui-input-block">
                                            <select lay-verify="required" name="gender">
                                                <option value="1" selected >男</option>
                                                <option value="0" >女</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn layui-btn-primary" onclick="window.location.href='login'">返回登录</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep">
                                                &emsp;下一步&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <input type="hidden" value="" name="id" id="id">
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;text-align: center;">为了您的账号安全,您的新密码将发送至邮箱</div>
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;text-align: center;">由于网络原因,发送时间可能延长，请您耐心等待</div>
                                    <br>
                                    <br>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">您的邮箱:</label>
                                        <div class="layui-input-block">
                                            <input type="text" id="forgetEmail" name="forgetEmail"  class="layui-input" readonly="readonly" value=""/>
                                        </div>
                                    </div>
                                    <br>
                                    <br>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep2">
                                                &emsp;立即发送&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <div style="text-align: center;margin-top: 90px;">
                                    <i class="layui-icon layui-circle"
                                       style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
                                    <div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
                                        修改成功
                                    </div>
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;">欢迎使用在线考试系统</div>
                                </div>
                                <div style="text-align: center;margin-top: 50px;">
                                    <button class="layui-btn layui-btn-primary" onclick="window.location.href='login'">返回登录</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<script src="${basePath}/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="${basePath}/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use([ 'form', 'step','jquery'], function () {
        var $ = layui.$,
            form = layui.form,
            step = layui.step;

        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%', //设置容器宽度
            stepWidth: '750px',
            height: '500px',
            stepItems: [{
                title: '验证个人信息'
            }, {
                title: '修改个人密码'
            }, {
                title: '完成'
            }]
        });

        form.on('submit(formStep)', function (data) {
            data = data.field;
            $.ajax({
                url:'forget/do',
                type:'post',
                data:data,
                dataType:'json',
                success:function (res){
                    if (res.code==0){
                        $("#forgetEmail").val(data.email);
                        $("#id").val(res.forgetId);
                        layer.msg(res.msg,function (){
                            step.next('#stepForm');
                        });
                    }else {
                        layer.alert(res.msg);
                    }
                }
            })
            return false;
        });

        form.on('submit(formStep2)', function (data) {
            data = data.field;

            $.ajax({
                url:'forget/execute',
                type:'get',
                data:{'id':data.id,'email':data.forgetEmail},
                dataType: 'json',
                success:function (res){
                    if(res.code===0){
                        layer.msg(res.msg,function (){
                            step.next('#stepForm');
                        });
                    }else {
                        layer.alert(res.msg);
                    }
                }
            })
            return false;
        });

        $('.pre').click(function () {
            step.pre('#stepForm');
        });

        $('.next').click(function () {
            step.next('#stepForm');
        });

    })
</script>
</body>
</html>